package com.leyou.item.client;

import com.leyou.common.pojo.PageResult;
import com.leyou.item.dto.SpecGroupDTO;
import com.leyou.item.dto.SpuDTO;
import com.leyou.item.pojo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 商品远程接口
 */
@FeignClient("item-service")
public interface ItemClient {

    /**
     * 商品列表查询
     */
    @GetMapping("/spu/page")
    public PageResult<SpuDTO> spuPageQuery(
            @RequestParam(value = "page",defaultValue = "1") Integer page,
            @RequestParam(value = "rows",defaultValue = "5") Integer rows,
            @RequestParam(value = "key",required = false) String key,
            @RequestParam(value = "saleable",required = false) Boolean saleable
    );

    /**
     * 根据spuId查询所有Sku
     */
    @GetMapping("/sku/of/spu")
    public List<Sku> findSkusBySpuId(@RequestParam("id") Long id);

    /**
     * 根据条件查询规格参数
     */
    @GetMapping("/spec/params")
    public List<SpecParam> findSpecParams(
            @RequestParam(value = "gid",required = false) Long gid,
            @RequestParam(value = "cid",required = false) Long cid,
            @RequestParam(value = "searching",required = false) Boolean searching
    );

    /**
     * 根据spuId查询SpuDetail
     */
    @GetMapping("/spu/detail")
    public SpuDetail findSpuDetailBySpuId(@RequestParam("id") Long id);

    /**
     * 根据分类ID集合查询分类集合
     */
    @GetMapping("/category/list")
    public List<Category> findCategoriesByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据id查询批量查询品牌
     */
    @GetMapping("/brand/list")
    public List<Brand> findBrandsByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据spuId查询Spu信息
     */
    @GetMapping("/spu/{id}")
    public SpuDTO findSpuById(@PathVariable("id") Long id);

    /**
     * 根据ID查询品牌
     * @RequestParam vs @PathVariable 的用法
     *    1）@RequestParam接收接收普通参数，  例如： /user?id=10
     *    2）@PathVariable接收路径参数， 例如 /user/10
     */
    @GetMapping("/brand/{id}")
    public Brand findBrandById(@PathVariable("id")Long id);

    /**
     * 根据分类ID（第3级）查询规格组列表（包含规格参数列表）
     */
    @GetMapping("/spec/of/category")
    public List<SpecGroupDTO> findSpecGroupDTOsByCid(@RequestParam("id") Long id);
}
